﻿package mortal.game.net.command.group
{
    import Framework.MQ.*;
    import Message.Public.*;
    import com.gengine.debug.*;
    import extend.language.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.game.scene3D.ai.ais.*;
    import mortal.game.view.group.*;
    import mortal.game.view.systemSetting.*;
    import mortal.mvc.core.*;

    public class GroupOperCommand extends BroadCastCall
    {

        public function GroupOperCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_4:int = 0;
            var _loc_5:Array = null;
            var _loc_6:SGroupOper = null;
            var _loc_7:Array = null;
            var _loc_8:SGroupOper = null;
            Log.debug("I have receive GroupOperCommand");
            var _loc_2:* = param1.messageBase as SGroupOper;
            var _loc_3:* = _loc_2.type;
            switch(_loc_3)
            {
                case EGroupOperType._EGroupOperTypeApply:
                {
                    _cache.group.addApplyList(_loc_2);
                    NetDispatcher.dispatchCmd(ServerCommand.GroupApply, null);
                    if (!_cache.group.autoEnter)
                    {
                        GroupSmallIcon.tabIndex = 3;
                        GroupSmallIcon.instance.show();
                    }
                    break;
                }
                case EGroupOperType._EGroupOperTypeInvite:
                {
                    _loc_4 = Cache.instance.role.entityInfo.level;
                    if (SystemSetting.instance.isRefuseBeAddToGroup.bValue)
                    {
                        _loc_5 = new Array();
                        _loc_6 = new SGroupOper();
                        _loc_6.fromEntityId = Cache.instance.role.entityInfo.entityId;
                        _loc_6.toEntityId = _loc_2.fromEntityId;
                        _loc_6.fromPlayer = new SPublicPlayer();
                        _loc_6.fromPlayer.entityId = Cache.instance.role.entityInfo.entityId;
                        _loc_6.type = EGroupOperType._EGroupOperTypeReject;
                        _loc_6.uid = _loc_2.uid;
                        _loc_6.fromPlayer.guildId = new SEntityId();
                        _loc_6.fromPlayer.copyId = new SEntityId();
                        _loc_5.push(_loc_6);
                        NetDispatcher.dispatchCmd(ServerCommand.AutoReject, _loc_5);
                        return;
                    }
                    if (_loc_4 >= 40 && AutoFightAI.isWorking && Cache.instance.autoFight.isAutoAcceptTeam)
                    {
                        _loc_7 = new Array();
                        _loc_8 = new SGroupOper();
                        _loc_8.fromEntityId = Cache.instance.role.entityInfo.entityId;
                        _loc_8.toEntityId = _loc_2.fromEntityId;
                        _loc_8.fromPlayer = new SPublicPlayer();
                        _loc_8.fromPlayer.entityId = Cache.instance.role.entityInfo.entityId;
                        _loc_8.type = EGroupOperType._EGroupOperTypeAgree;
                        _loc_8.uid = _loc_2.uid;
                        _loc_8.fromPlayer.guildId = new SEntityId();
                        _loc_8.fromPlayer.copyId = new SEntityId();
                        _loc_7.push(_loc_8);
                        NetDispatcher.dispatchCmd(ServerCommand.AutoReject, _loc_7);
                        return;
                    }
                    _cache.group.addInviteList(_loc_2);
                    NetDispatcher.dispatchCmd(ServerCommand.GroupInvite, null);
                    GroupSmallIcon.tabIndex = 4;
                    GroupSmallIcon.instance.show();
                    break;
                }
                case EGroupOperType._EGroupOperTypeRejectApply:
                {
                    MsgManager.showRollTipsMsg(_loc_2.fromPlayer.name + Language.getString(30251));
                    break;
                }
                case EGroupOperType._EGroupOperTypeRejectInvite:
                {
                    MsgManager.showRollTipsMsg(_loc_2.fromPlayer.name + Language.getString(30252));
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            return;
        }// end function

    }
}
